import { Injectable } from '@nestjs/common';
export interface User {
  id: number;
  name: string;
  email: string;
}
@Injectable()
export class DataService {
  private readonly users: User[] = [
    { id: 1, name: '张三', email: 'zhangsan@example.com' },
    { id: 2, name: '李四', email: 'lisi@example.com' },
    { id: 3, name: '王五', email: 'wangwu@example.com' },
  ];

  private readonly products = [
    { id: 1, name: '笔记本电脑', price: 5999 },
    { id: 2, name: '智能手机', price: 3999 },
    { id: 3, name: '平板电脑', price: 2999 },
  ];

  getAllUsers(): User[] {
    return this.users;
  }

  getUserById(id: number): User {
    return this.users.find(user => user.id === id);
  }

  getAllProducts() {
    return this.products;
  }

  getDataSummary() {
    return {
      totalUsers: this.users.length,
      totalProducts: this.products.length,
      lastUpdated: new Date().toISOString()
    };
  }
}